import sim, sim_items, main
from util import *
import random

class NimblePrefix(sim_items.Prefix):
    def __init__(self):
        super(NimblePrefix, self).__init__(
            "nimble", # name
            "This pair of handwear was crafted by the Thieves Guild, "
            "specially designed to provide greater freedom of movement "
            "to prying digits."
        )

    def initialize(self, wearable):
        if not isinstance(wearable, sim_items.Armor):
            raise ValueError('Tried to apply %r to non-armor item: %r' % (self,
                wearable))
        if 'hands' not in wearable.wearSlots:
            return 
        super(NimblePrefix, self).initialize(wearable)
        
        self.dexterityBonus = random.randint(1,3) 
        self.wearable.bonuses.update({
            'dexterityMod': self.wearable.bonuses['dexterityMod'] + self.dexterityBonus
        })

    def remove(self, wearable):
        super(NimblePrefix, self).remove(wearable)
        wearable.bonuses.update({
            'dexterityMod': self.wearable.bonuses['dexterityMod'] - self.dexterityBonus
        })

#========================================
thingClass = NimblePrefix
